﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using ExtAspNet;
using Ylh.BLL;


public partial class Module_StaffManger_RoleManger : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Button1.OnClientClick = Window1.GetShowReference("AddRole.aspx","添加角色信息");

        if (!IsPostBack)
        {
            BindGvList();
        }

    }

    private void BindGvList()
    {
        RoleBLL robll = new RoleBLL(DbConnectionStr);
        Grid1.DataSource = robll.GetRoleInFo(-1);
        Grid1.DataBind();
    }

    protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
    {
        string RoleID= Grid1.DataKeys[e.RowIndex][0].ToString();

        if (e.CommandName == "UpdateRole")
        {
            PageContext.RegisterStartupScript(Window2.GetShowReference("RoleTree.aspx?RoleID=" + RoleID, "选择权限"));
        }

        if (e.CommandName == "UpdateRoleInfo")
        {
            PageContext.RegisterStartupScript(Window1.GetShowReference("AddRole.aspx?RoleID=" + RoleID, "修改角色信息"));
        }
    }


    protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
    {
        Grid1.PageIndex = e.NewPageIndex;
    }

    protected void BtnDel_Click(object sender, EventArgs e)
    {

        List<string> li= GetCheckID(Grid1);

        if (li.Count==0)
        {
            Alert.Show("当前没有选中任何记录");
        }

        RoleBLL robll = new RoleBLL(DbConnectionStr);

        robll.Delete(li);

        BindGvList();

        Alert.Show("删除操作已经完成,但是已经被员工使用了的角色不能删除");

        
    }
    protected void BtnReflsh_Click(object sender, EventArgs e)
    {
        BindGvList();
    }


    protected void Window1_Close(object sender, WindowCloseEventArgs e)
    {
        BindGvList();
    }




}